<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
      }
      .drop-content {
        width: 200px;
        height: 200px;
        border: 2px dashed #000;
      }
      .drag-box {
        background-color: red;
        color: #fff;
        width: 100px;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <div class="drop-content"></div>
    <div class="drag-box" draggable="true">拖拽元素</div>
    <script>
      const dropContent = document.querySelector(".drop-content");
      const dragBox = document.querySelector(".drag-box");

      dropContent.addEventListener("dragover", (e) => e.preventDefault());
      dropContent.addEventListener("drop", (e) => {
        dropContent.appendChild(dragBox);
      });
    </script>
  </body>
</html>
